<?php
declare (strict_types=1);

namespace app\admin\controller;

use addons\BuilderPlus\components\Column;
use addons\BuilderPlus\components\Search;
use addons\BuilderPlus\facade\Table;

class Logs extends Base
{
    public function getOptions(): array
    {
        return [
            'pk' => 'id',
            'model' => \app\common\model\Logs::class
        ];
    }

    public function index(): string
    {
        return Table::init($this)
            ->setCheckbox(false)
            ->addColumns([
                ['id', 'ID', fn(Column $col) => $col->width(80)],
                ['emp_name', '操作人', fn(Column $col) => $col->width(150)],
                ['ip', '操作IP', fn(Column $col) => $col->width(120)],
                ['event', '操作方法', fn(Column $col) => $col->width(120)],
                ['description', '描述', fn(Column $col) => $col->templet('{{d.description}}')],
                ['create_time', '时间', fn(Column $col) => $col->width(150)],
            ])
            ->addSearch([
                ['create_time', '操作时间', fn(Search $search) => $search->type('date')],
                ['emp_name__ip', '会员编号/管理员账号/IP地址', fn(Search $search) => $search->condition('Like')],
                ['description', '输入关键字', fn(Search $search) => $search->condition('Like')]
            ])
            ->fetch();
    }
}